Benefits.
Project contracts (legal doc.) or charters (organisational doc.) allow project managers and sponsors to clarify the content and the outcome of the project.
When to apply?
As soon as you receive a positive answer about funding from a sponsor.
How to?
Both documents describe at least the situation, the purpose of the project, what belongs to it / what is excluded and the amount of funding.
Project charters have a WBS, a Gantt chart, a resource plan and an organisation chart. Contracts only include this info if legally relevant.